"""
grid.py --                                                                                            
                                                                                                                                                                                                        
It sets the world's grid parameters.                                              
                                                                                                                                                                                                            
Date of creation: 2007-03-17                                                                        
                                                                                                                                                                                                
Copyright  Robotics and Automation Group, Pontificia Universidad Javeriana - Cali.                  
    Freddy Naranjo Perez, fnaranjo@puj.edu.co                                                                   
    Antonio Alejandro Matta Gomez amatta@puj.edu.co                                      
    Julian David Colorado, jdcolorado@puj.edu.co                           
    Juan Camilo Acosta Mejia, jcacosta@puj.edu.co                                    
                                                                                                                                                                                                        
See the file "license.terms" for information on usage and redistribution of this file, and for a    
DISCLAIMER OF ALL WARRANTIES.
"""

import vtk



class Grid:
  def __init__( self, ren ):
        """ Inits world grid and associated texture"""
        
        # Load in the texture map. A texture is any unsigned char image. If it
        # is not of this type, you will have to map it through a lookup table
        # or by using vtkImageShiftScale.
        bmpReader = vtk.vtkBMPReader()
        bmpReader.SetFileName("graphengine/textures/floor4.bmp")
        self.gridtext = vtk.vtkTexture()
        self.gridtext.SetInputConnection(bmpReader.GetOutputPort())
        self.gridtext.InterpolateOn()
        
        # Create a plane source and actor. The vtkPlanesSource generates
        # texture coordinates.
        self.plane = vtk.vtkPlaneSource()
        self.plane.SetOrigin( -2.0,0.0,-2.0 )
        self.plane.SetPoint1( 2.0,0.0,-2.0 )
        self.plane.SetPoint2( -2.0,0.0,2.0 )
        self.planeMapper = vtk.vtkPolyDataMapper()
        self.planeMapper.SetInputConnection(self.plane.GetOutputPort())
        self.planeActor = vtk.vtkActor()
        self.planeActor.SetMapper(self.planeMapper)
        self.planeActor.SetTexture(self.gridtext)
        
        ren.AddActor(self.planeActor)
   
    
        
    
    

        
        
            
        
    

    
  
  